Fix typings of ExceptionGroup and BaseExceptionGroup#9230
Fix typings of ExceptionGroup and BaseExceptionGroup#9230JelleZijlstra merged 13 commits intopython:mainfrom
ExceptionGroup and BaseExceptionGroup#9230Conversation
|
Ok, pyright has only 10 problems: I will add a version guard later on. |
This comment has been minimized.
This comment has been minimized.
|
Looks like we need some other solution for unused |
This comment has been minimized.
This comment has been minimized.
|
|
||
| # `BaseExceptionGroup` can work with `Exception`: | ||
| beg2 = BaseExceptionGroup("x", [ValueError()]) | ||
| # FIXME: this is not right, runtime returns `ExceptionGroup` instance instead, |
There was a problem hiding this comment.
Should be doable by overriding __new__ (python/mypy#7188), did you try that?
There was a problem hiding this comment.
We have three cases:
BaseExceptionGroup.__new__can returnBaseExceptionGroupfor_BaseExceptionT_coBaseExceptionGroup.__new__can returnExceptionGroupfor_ExceptionT_coBaseExceptionGroup.__new__can return custom subclass
Either the first two work or the third one. Suggestions are welcome
|
I have an idea for how to fix the test cases on mypy; I'll get to work on a fix. For flake8: would an alternative fix be to have |
This comment has been minimized.
This comment has been minimized.
|
@AlexWaygood, thank you, flake8 idea worked! |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
|
Hooray, CI is finally green 🎉 |
|
I really hope this is correct now! Ping me in case of any problems. |
There are a lot of things going on in this PR:
Selftype, because of howCimplementation workssplitandsubgrouprequireSelfargument to be in callable, because of howCimplementation worksBaseExceptionGroupto and fromExceptionGroupare supported. But not all of themThis is a very complex PR. I would love to provide any of my help to the reviewers.